package arithmetic;

import java.util.Scanner;
import java.util.Stack;

/**
 * @program: javaLearn
 * @description: 回文整数
 * @author: renhai
 * @Date ：2022/4/7 22:43
 **/
public class PalindromeInteger {

    public static boolean isPalindrome(int x) {
        String s = String.valueOf(x);
        Stack<String> stc = new Stack<>();
        for (int i = 0; i < s.length() / 2; i++) {
            stc.push(s.substring(i, i + 1));
        }
        StringBuilder s1 = new StringBuilder();
        while (!stc.isEmpty()) {
            s1.append(stc.pop());
        }
        int len = 0;
        if (s.length() % 2 == 0) {
            len = s.length() / 2;
        } else {
            len = s.length() / 2 + 1;
        }
        return (s.substring(len)).equals(new String(s1));
    }

    public static void main(String[] args) {

        System.out.println(isPalindrome(121));

    }
}
